'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database()
	const dbName = event.dbName
	if (event.type == 'update') {
		let res = await db.collection(dbName).doc(event.id).get()
		console.log('查询', res)
		let obj = res.data[0]
		let resnew = await db.collection(dbName).doc(event.id).update({
			enrollment: event.typeAction == 'add' ? obj.enrollment + 1 : obj.enrollment - 1
		});
		//返回数据给客户端
		return resnew
	}

};